package Enums;

import java.lang.reflect.Field;

public class Demo {

    Sex sex = Sex.male;


    public enum Sex {
        male("man", 10),
        female("woman", 11);
        String humanType;
        int id;

        private Sex(String humanType, int id) {
            this.humanType = humanType;
            this.id = id;
        }

        public void print() {
            System.out.println(humanType + "  " + id);
        }
    }


    public static void main(String[] args) throws Exception {

        Sex male = Sex.valueOf("male");
        System.out.println(male.ordinal());
        System.out.println(male.name());
        male.print();
        // 反射API
        Sex human = Sex.male;
        System.out.println(human.getClass().isEnum());
        Sex[] sexs = human.getClass().getEnumConstants();
        System.out.println(sexs[1].name());
        Field field = Demo.class.getDeclaredField("sex");
        System.out.println(field.getType().isEnum());

    }
}
